package com.zklh.leetcode.tree.middle;

import com.zklh.leetcode.tree.model.TreeNode;

/**
 * @author ：tong nan
 * @date ：Created in 2021/5/15 10:39
 * @description ：二叉搜索书插入器
 * @modifiedBy ：
 */
public class BinaryTreeInserter {


    public TreeNode insert(TreeNode root, int val) {

        if (root == null) {
            return new TreeNode(val);
        }
        if (val > root.val) {
            root.right = insert(root.right, val);
        } else {
            root.left = insert(root.left, val);
        }
        return root;
    }

}
